package cn.mill.demo.api.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.mill.demo.open.OpenApi;
import cn.mill.demo.postcode.Param;
import cn.mill.demo.postcode.PostCodeHandler;
import cn.mill.demo.weixin.Access;
import cn.mill.demo.weixin.WeixinHandler;

@RestController
public class IndexController {
	
	@Autowired
	private WeixinHandler weixinHandler;
	
	@Autowired
	private PostCodeHandler postCodeHandler;
	
	@Autowired
	private OpenApi openApi;
	
	@RequestMapping("/index")
	public String t(HttpServletRequest request, HttpServletResponse response) {
		Access a = weixinHandler.getAccessToken("wx07f763d98abd3806", "50385494e41785c37aeca313498ef4ed");
		return weixinHandler.getWeiXinIp(a).toString();
	}
	
	@RequestMapping("/index1")
	public String t2(HttpServletRequest request, HttpServletResponse response) {
		Param param = new Param();
		param.setProvince("河北省");
		return postCodeHandler.getPostCode(param).toString();
	}
	
	@RequestMapping("/musics")
	public String musics(HttpServletRequest request, HttpServletResponse response) {
		;
		return openApi.musics().toString();
	}
}
